let animationShowHeight = 300;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    showModalStatus: false,
    showModalStatus2: false,
    deptEnabled: false,//部门项启用状态
    faxEnabled: false,//传真项启用状态
    qqEnabled: false,//传真项启用状态
    name: '',
    job: '',
    mobile: '',
    phone: '',
    wechat: '',
    microblog: '',
    email: '',
    address: '',
    qq: '',
    department: '',
    fax: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          windowHeight: res.windowHeight-180 + 'px'
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  showModal: function (e) {
    // 显示遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    animation.translateY(animationShowHeight).step()
    this.setData({
      animationData: animation.export(),
      showModalStatus: true,
      showModalStatus2: false
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export()
      })
    }.bind(this), 200)


  },
  hideModal: function () {
    // 隐藏遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation;
    animation.translateY(animationShowHeight).step()
    this.setData({
      animationData: animation.export(),
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export(),
        showModalStatus: false
      })
    }.bind(this), 200)
  },

  showModal2: function (e) {
    // 显示遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    animation.translateY(animationShowHeight).step()
    this.setData({
      animationData: animation.export(),
      showModalStatus: false,
      showModalStatus2: true
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData2: animation.export()
      })
    }.bind(this), 200)


  },
  hideModal2: function () {
    // 隐藏遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation;
    animation.translateY(animationShowHeight).step()
    this.setData({
      animationData2: animation.export(),
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData2: animation.export(),
        showModalStatus2: false
      })
    }.bind(this), 200)
  },
  addItem: function () {
    this.setData({
      showModalStatus: true
    })
  },
  //添加更多项目
  bindAddItem: function (e) {
    var value = e.currentTarget.dataset.value
    switch (value) {
      case 'dept':
        this.setData({
          deptEnabled: true,
        })
        break;
      case 'fax':
        this.setData({
          faxEnabled: true,
        })
        break;
      case 'qq':
        this.setData({
          qqEnabled: true,
        })
        break;

    }
  },
  preview: function () {
    this.setData({
      showModalStatus2: true
    })
  },
  //监听姓名输入
  nameInput: function (e) {
    this.setData({
      name: e.detail.value
    })
  },
  //监听职称输入
  jobInput: function (e) {
    this.setData({
      job: e.detail.value
    })
  },
  //监听手机输入
  mobileInput: function (e) {
    this.setData({
      mobile: e.detail.value
    })
  },
  //监听固话输入
  phoneInput: function (e) {
    this.setData({
      phone: e.detail.value
    })
  },
  //监听微信输入
  wechatInput: function (e) {
    this.setData({
      wechat: e.detail.value
    })
  },
  //监听qq输入
  qqInput: function (e) {
    this.setData({
      qq: e.detail.value
    })
  },
  //监听微博输入
  microblogInput: function (e) {
    this.setData({
      microblog: e.detail.value
    })
  },
  //监听地址输入
  addressInput: function (e) {
    this.setData({
      address: e.detail.value
    })
  },
  //监听邮箱输入
  emailInput: function (e) {
    this.setData({
      email: e.detail.value
    })
  },
  //监听部门输入
  departmentInput: function (e) {
    this.setData({
      department: e.detail.value,

    })
  },
  //监听传真输入
  faxInput: function (e) {
    this.setData({
      fax: e.detail.value
    })
  },
  next:function(){
    wx.navigateTo({
      url: '/pages/template/make-card/generate-code',
    })
  }

})